$(function(){
	// common.goBackNext();
	var token=common.getToken();
	var agentInfo=common.getLocalData('H5-agentInfo');
	var globalHost=common.globalHost;
	var imageHost=common.imageHost;
	var getDetail=common.getAgentDetailPort;
	var url=globalHost+getDetail;
	var sendData={
		token:token,
		id:agentInfo.id
	};
	var $headImg=$('#headImg');
	var $personalEnounce=$('#personalEnounce');
	var $agentName=$('#agentName');
	var $mobile=$('#mobile');
	var $workLife=$('#workLife');
	var $storeName=$('#storeName');
	var $hostoryGlory=$('#hostoryGlory');
	var $groupPhoto=$('#group-photo');
	var $groupPhotoList=$('#groupPhotoList');
	common.requestFormData({
		url:url,
		sendData:sendData,
		resSuccess:function(data){
			var data=data.res.data;
			var isPerfect=data['isPerfect'];
			$.each(data,function (key,value) {
		        if(!!value){
	        		$("#"+key).html(value);
	        	}
		     });
			if(isPerfect==1){
				var headImg=data['perfect']['headImage'];
					headImg?$headImg.css({'backgroundImage':'url('+imageHost+headImg+')'}).addClass('diamond'):'';
		        $.each(data['perfect'],function (key,value) {
		        	if(!!value){
		        		$("#"+key).html(value);
		        	}
		        });
				var workLife=data['perfect']['workLife'];
					workLife===""?$workLife.html("未填").parent().show():$workLife.html(workLife+'&nbsp;年').parent().show();
				var visitHouses=data['perfect']['visitHouses'];
				if(visitHouses===""){
					visitHouses='<li><p>带看房源数：</p><div>未填</div></li>';
				}else{
					var visitHousesCompare=data['perfect']['visitHousesCompare']?data['perfect']['visitHousesCompare']:"";
					if(!!visitHousesCompare){
						visitHouses='<li><p>带看房源数：</p><div>'+visitHouses+'</div><address>高于同行业'+visitHousesCompare+'%</address></li>';
					}else{
						visitHouses='<li><p>带看房源数：</p><div>'+visitHouses+'</div></li>';
					}
				}
				var serviceCustomers=data['perfect']['serviceCustomers'];
				if(serviceCustomers===""){
					serviceCustomers='<li><p>服务客户数：</p><div>未填</div></li>';
				}else{
					var serviceCustomersCompare=data['perfect']['serviceCustomersCompare']?data['perfect']['serviceCustomersCompare']:"";
					if(!!serviceCustomersCompare){
						serviceCustomers='<li><p>服务客户数：</p><div>'+serviceCustomers+'</div><address>高于同行业'+serviceCustomersCompare+'%</address></li>';
					}else{
						serviceCustomers='<li><p>服务客户数：</p><div>'+serviceCustomers+'</div></li>';
					}
				}
				var dealCustomers=data['perfect']['dealCustomers'];
				if(dealCustomers===""){
					dealCustomers='<li><p>成交客户数：</p><div>未填</div></li>';
				}else{
					var dealCustomersCompare=data['perfect']['dealCustomersCompare']?data['perfect']['dealCustomersCompare']:"";
					if(!!dealCustomersCompare){
						dealCustomers='<li><p>成交客户数：</p><div>'+dealCustomers+'</div><address>高于同行业'+dealCustomersCompare+'%</address></li>';
					}else{
						dealCustomers='<li><p>成交客户数：</p><div>'+dealCustomers+'</div></li>';
					}
				}
				var tempDOM=visitHouses+serviceCustomers+dealCustomers;
				$hostoryGlory.html(tempDOM);
				var groupPhoto=data['perfect']['groupPhoto'];
				if(!!groupPhoto){
					buildNormalSlider({
						imageHost:imageHost,
						dataList:groupPhoto.split(","),
						targetSelector:$groupPhotoList
					});
					var swiper1 = new Swiper($groupPhoto, {
						pagination:'.swiper-pagination',
						paginationClickable: true,
					    slidesPerView: 'auto',
					    spaceBetween: 10
					});
				}
				
			}else{

			}
		},
		resFailed:function(data){
           
		},
		resError:function(data){
			
		}
	})
})

function buildNormalSlider(options){
	var targetSelector=options.targetSelector;
	var dataList=options.dataList;
	var imageHost=options.imageHost;
	var arrTemp=[];
	$.each(dataList,function(idx,ele){
		var photoDOM='<li class="swiper-slide"><img src="'+imageHost+ele+'" alt=""></li>'
		arrTemp.push(photoDOM);
	});
	targetSelector.html(arrTemp.join(""));
};